package br.ufsm.inf.zebraloqacliente.activities;

import br.ufsm.inf.zebraloqacliente.R;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.app.ActionBar;
import android.content.Intent;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Button debug = (Button) findViewById(R.id.debug_login);
        debug.setOnClickListener(new View.OnClickListener() {
 
            public void onClick(View v) {
                // Switching to Register screen
                // Intent i = new Intent(getApplicationContext(), LoginActivity.class);
            	Intent i = new Intent(getApplicationContext(), BrowserActivity.class);
            	i.putExtra("url", "http://zebraloqa.pythonanywhere.com/admin");
                startActivity(i);
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        
        ActionBar actionBar = getActionBar();
        //actionBar.setSubtitle("Zebra Loqa");
        actionBar.setTitle(""); 
        
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	Intent i;
        switch (item.getItemId()) {
	      	case R.id.busca:
	      		i = new Intent(getApplicationContext(), BrowserActivity.class);
	        	i.putExtra("url", "http://zebraloqa.pythonanywhere.com/");
	            startActivity(i);
	      		break;
	    	  
	      	case R.id.qr_code:	      		
	      		i = new Intent(getApplicationContext(), LerQRCodeActivity.class);
                startActivity(i);
	      		break;
	        
	      	case R.id.perfil:
	      		i = new Intent(getApplicationContext(), BrowserActivity.class);
	        	i.putExtra("url", "http://zebraloqa.pythonanywhere.com/accounts/profile/");
	            startActivity(i);
	      		break;
	          
	      	case R.id.carrinho:
	      		i = new Intent(getApplicationContext(), BrowserActivity.class);
	        	i.putExtra("url", "http://zebraloqa.pythonanywhere.com/loja/carrinho/last/");
	            startActivity(i);
	      		break;
	
	      	default:
	      		break;
        }

        return true;
    }
    
}
